
function sendAction(action) {
	$.ajax({
		type : 'Get',
		timeout: 1000, 
		url  : './Engine',
		data : "param=" + action,
		async : true,
		cache : false,
		contentType : 'application/x-javascript',
		success : function(data) {
			console.log(data);
		},
		error : function(XMLHttpRequest, textstatus, error) { 
			console.log(error);
			sendAction(action);
		}		
	});
}


function isGameRunning(){
	$.ajax({
		type : 'Get',
		timeout: 1000, 
		url  : './Engine',
		data : "param=isGameRunning",
		async : true,
		cache : false,
		contentType : 'application/x-javascript',
		success : function(data) {
			eval(data);
			startGame(running);
		},
		error : function(XMLHttpRequest, textstatus, error) { 
			console.log(error);
		}		
	});
}

function endGameInServer(){
	$.ajax({
		type : 'Get',
		timeout: 1000, 
		url  : './Engine',
		data : "param=leave",
		async : true,
		cache : false,
		contentType : 'application/x-javascript',
		success : function(data) {
			//blah.
		},
		error : function(XMLHttpRequest, textstatus, error) { 
			console.log(error);
		}		
	});
}

function sendMessage(message){
	$.ajax({
		type : 'Get',
		timeout: 10000, 
		url  : './Engine',
		data : "param=msg&message=" + message,
		async : true,
		cache : false,
		contentType : 'application/x-javascript',
		success : function(data) {
			
		},
		error : function(XMLHttpRequest, textstatus, error) { 
			console.log(error);
		}		
	});
}